.class public Lrexsee/core/widget/RatingStars;
.super Landroid/widget/LinearLayout;
.source "RatingStars.java"


# instance fields
.field private final isStar10:Z

.field private final mDensity:F

.field private rating:I

.field private final starLayout:Landroid/widget/LinearLayout;

.field private final titleText:Landroid/widget/TextView;


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;IZ)V
    .locals 11
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "title"    # Ljava/lang/String;
    .param p3, "init"    # I
    .param p4, "star10"    # Z

    .prologue
    const/4 v10, 0x2

    const/4 v9, -0x1

    const/4 v8, 0x0

    const/4 v7, -0x2

    const/4 v6, 0x5

    .line 23
    invoke-direct {p0, p1}, Landroid/widget/LinearLayout;-><init>(Landroid/content/Context;)V

    .line 24
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v2

    invoke-virtual {v2}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;

    move-result-object v2

    iget v2, v2, Landroid/util/DisplayMetrics;->density:F

    iput v2, p0, Lrexsee/core/widget/RatingStars;->mDensity:F

    .line 25
    iput-boolean p4, p0, Lrexsee/core/widget/RatingStars;->isStar10:Z

    .line 26
    invoke-virtual {p0, v8}, Lrexsee/core/widget/RatingStars;->setOrientation(I)V

    .line 27
    const/16 v2, 0x10

    invoke-virtual {p0, v2}, Lrexsee/core/widget/RatingStars;->setGravity(I)V

    .line 28
    new-instance v2, Landroid/widget/TextView;

    invoke-direct {v2, p1}, Landroid/widget/TextView;-><init>(Landroid/content/Context;)V

    iput-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    .line 29
    if-eqz p2, :cond_0

    const-string v2, ""

    invoke-virtual {p2, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_0

    .line 30
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    invoke-virtual {v2, v8}, Landroid/widget/TextView;->setId(I)V

    .line 31
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    const/high16 v3, 0x41900000    # 18.0f

    invoke-virtual {v2, v3}, Landroid/widget/TextView;->setTextSize(F)V

    .line 32
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    invoke-direct {p0, v6}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v3

    invoke-direct {p0, v6}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v4

    invoke-direct {p0, v6}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v5

    invoke-virtual {v2, v8, v3, v4, v5}, Landroid/widget/TextView;->setPadding(IIII)V

    .line 33
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    invoke-virtual {v2, v9}, Landroid/widget/TextView;->setTextColor(I)V

    .line 34
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    invoke-static {p2}, Landroid/text/Html;->fromHtml(Ljava/lang/String;)Landroid/text/Spanned;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 35
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->titleText:Landroid/widget/TextView;

    new-instance v3, Landroid/widget/LinearLayout$LayoutParams;

    invoke-direct {v3, v7, v7}, Landroid/widget/LinearLayout$LayoutParams;-><init>(II)V

    invoke-virtual {p0, v2, v3}, Lrexsee/core/widget/RatingStars;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 37
    :cond_0
    new-instance v2, Landroid/widget/LinearLayout;

    invoke-direct {v2, p1}, Landroid/widget/LinearLayout;-><init>(Landroid/content/Context;)V

    iput-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    .line 38
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    invoke-virtual {v2, v8}, Landroid/widget/LinearLayout;->setOrientation(I)V

    .line 39
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    const/16 v3, 0x10

    invoke-virtual {v2, v3}, Landroid/widget/LinearLayout;->setGravity(I)V

    .line 40
    const/4 v0, 0x0

    .local v0, "i":I
    :goto_0
    if-eqz p4, :cond_3

    const/16 v2, 0xa

    :goto_1
    if-lt v0, v2, :cond_1

    .line 59
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    new-instance v3, Landroid/widget/LinearLayout$LayoutParams;

    invoke-direct {v3, v9, v7}, Landroid/widget/LinearLayout$LayoutParams;-><init>(II)V

    invoke-virtual {p0, v2, v3}, Lrexsee/core/widget/RatingStars;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 60
    iput p3, p0, Lrexsee/core/widget/RatingStars;->rating:I

    .line 61
    invoke-direct {p0}, Lrexsee/core/widget/RatingStars;->setRating()V

    .line 62
    return-void

    .line 41
    :cond_1
    new-instance v1, Landroid/widget/TextView;

    invoke-direct {v1, p1}, Landroid/widget/TextView;-><init>(Landroid/content/Context;)V

    .line 42
    .local v1, "star":Landroid/widget/TextView;
    const/16 v2, 0x11

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setGravity(I)V

    .line 43
    invoke-direct {p0, v10}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v2

    invoke-direct {p0, v6}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v3

    invoke-direct {p0, v10}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v4

    invoke-direct {p0, v6}, Lrexsee/core/widget/RatingStars;->scale(I)I

    move-result v5

    invoke-virtual {v1, v2, v3, v4, v5}, Landroid/widget/TextView;->setPadding(IIII)V

    .line 44
    if-eqz p4, :cond_2

    const/16 v2, 0x16

    :goto_2
    int-to-float v2, v2

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setTextSize(F)V

    .line 45
    const/4 v2, 0x1

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setClickable(Z)V

    .line 46
    new-instance v2, Lrexsee/core/widget/RatingStars$1;

    invoke-direct {v2, p0}, Lrexsee/core/widget/RatingStars$1;-><init>(Lrexsee/core/widget/RatingStars;)V

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setOnTouchListener(Landroid/view/View$OnTouchListener;)V

    .line 57
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    new-instance v3, Landroid/widget/LinearLayout$LayoutParams;

    const/high16 v4, 0x3f800000    # 1.0f

    invoke-direct {v3, v9, v7, v4}, Landroid/widget/LinearLayout$LayoutParams;-><init>(IIF)V

    invoke-virtual {v2, v1, v3}, Landroid/widget/LinearLayout;->addView(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V

    .line 40
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 44
    :cond_2
    const/16 v2, 0x28

    goto :goto_2

    .end local v1    # "star":Landroid/widget/TextView;
    :cond_3
    move v2, v6

    .line 40
    goto :goto_1
.end method

.method static synthetic access$0(Lrexsee/core/widget/RatingStars;I)V
    .locals 0

    .prologue
    .line 16
    iput p1, p0, Lrexsee/core/widget/RatingStars;->rating:I

    return-void
.end method

.method static synthetic access$1(Lrexsee/core/widget/RatingStars;)V
    .locals 0

    .prologue
    .line 63
    invoke-direct {p0}, Lrexsee/core/widget/RatingStars;->setRating()V

    return-void
.end method

.method private scale(I)I
    .locals 2
    .param p1, "pixel"    # I

    .prologue
    .line 20
    iget v0, p0, Lrexsee/core/widget/RatingStars;->mDensity:F

    int-to-float v1, p1

    mul-float/2addr v0, v1

    invoke-static {v0}, Ljava/lang/Math;->round(F)I

    move-result v0

    return v0
.end method

.method private setRating()V
    .locals 3

    .prologue
    .line 64
    const/4 v0, 0x0

    .local v0, "i":I
    :goto_0
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    invoke-virtual {v2}, Landroid/widget/LinearLayout;->getChildCount()I

    move-result v2

    if-lt v0, v2, :cond_0

    .line 74
    return-void

    .line 65
    :cond_0
    iget-object v2, p0, Lrexsee/core/widget/RatingStars;->starLayout:Landroid/widget/LinearLayout;

    invoke-virtual {v2, v0}, Landroid/widget/LinearLayout;->getChildAt(I)Landroid/view/View;

    move-result-object v1

    check-cast v1, Landroid/widget/TextView;

    .line 66
    .local v1, "s":Landroid/widget/TextView;
    iget v2, p0, Lrexsee/core/widget/RatingStars;->rating:I

    if-ge v0, v2, :cond_1

    .line 67
    const/16 v2, -0x100

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setTextColor(I)V

    .line 68
    const-string v2, "\u2605"

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 64
    :goto_1
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 70
    :cond_1
    const v2, -0x777778

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setTextColor(I)V

    .line 71
    const-string v2, "\u2606"

    invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    goto :goto_1
.end method


# virtual methods
.method public getRating()I
    .locals 3

    .prologue
    const/16 v2, 0xa

    const/4 v1, 0x5

    .line 76
    iget v0, p0, Lrexsee/core/widget/RatingStars;->rating:I

    if-gez v0, :cond_0

    const/4 v0, 0x0

    .line 80
    :goto_0
    return v0

    .line 77
    :cond_0
    iget-boolean v0, p0, Lrexsee/core/widget/RatingStars;->isStar10:Z

    if-eqz v0, :cond_2

    .line 78
    iget v0, p0, Lrexsee/core/widget/RatingStars;->rating:I

    if-le v0, v2, :cond_1

    move v0, v2

    goto :goto_0

    :cond_1
    iget v0, p0, Lrexsee/core/widget/RatingStars;->rating:I

    goto :goto_0

    .line 80
    :cond_2
    iget v0, p0, Lrexsee/core/widget/RatingStars;->rating:I

    if-le v0, v1, :cond_3

    move v0, v1

    goto :goto_0

    :cond_3
    iget v0, p0, Lrexsee/core/widget/RatingStars;->rating:I

    goto :goto_0
.end method
